package com.zhu.androidsample.business.phonelocation.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.zhu.androidsample.R;
import com.zhu.androidsample.business.phonelocation.bean.PhoneLocationBean;

/**
 * Created by KnightYe on 2015/12/3.
 * email:43426073@qq.com
 */
public class PhoneLocationView extends FrameLayout {

    TextView city_code;
    TextView city_name;
    TextView operator;
    TextView province;
    TextView post_code;

    public PhoneLocationView(Context context) {
        super(context);
        init(context);
    }

    public PhoneLocationView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public PhoneLocationView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);

    }

    void init(Context context) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rootView = inflater.inflate(R.layout.view_phone_location, this, false);
        city_code = (TextView) rootView.findViewById(R.id.pl_city_code);
        city_name = (TextView) rootView.findViewById(R.id.pl_city_name);
        operator = (TextView) rootView.findViewById(R.id.pl_operator);
        province = (TextView) rootView.findViewById(R.id.pl_city_province);
        post_code = (TextView) rootView.findViewById(R.id.pl_post_code);
        this.addView(rootView);
    }

    public void setBean(PhoneLocationBean bean) {
        city_code.setText(bean.getAreaCode());
        city_name.setText(bean.getCity());
        operator.setText(bean.getName());
        province.setText(bean.getProv());
        post_code.setText(bean.getPostCode());
    }

}
